package complexity.cohesion;

import java.util.ArrayList;
import java.util.List;

public class LineCommentDeleter {


	
	public String LineCommentCheckerAndDeleter(String sCurrentLine)  //asdasdasd asdasdasd
	{//asdasdasd asdasdasd
		List<Character> lineList = new ArrayList<Character>();
		List<Character> charOfLine = new ArrayList<Character>();
		
		int commentFlag = 0;
		
		if(sCurrentLine.isEmpty() != true)
		{
			for(char ch : sCurrentLine.toCharArray())
			{
				lineList.add(ch);
			}
			
			for(char c : lineList)
			{
				if(commentFlag != 1)
					charOfLine.add(c);
				
				if(c == '/' && commentFlag != 1)
				{
					commentFlag = 1;
					continue;
				}
				
				
				if(commentFlag == 1)
				{
					if(c == '/')
					{
						commentFlag = 0;
						charOfLine.remove(charOfLine.size()-1);
						break;
					}
				}
			}
			
			StringBuilder lineWOLineComment = new StringBuilder(charOfLine.size());
		    for(Character ch: charOfLine)
		    {
		    	lineWOLineComment.append(ch);
		    } 

		    return lineWOLineComment.toString();
		}
		else 
			return null;

	}	
}
